/*
Copyright [2023] [fuwen_soft]
*/
package vip.xiaonuo.modular.xygenealogy.controller;

import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.modular.xygenealogy.param.XyGenealogyParam;
import vip.xiaonuo.modular.xygenealogy.service.XyGenealogyService;
import vip.xiaonuo.modular.xygenealogy.entity.XyGenealogy;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.core.annotion.version.AdminVersionSwagger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.List;
import vip.xiaonuo.sys.core.msg.Result;
import static vip.xiaonuo.sys.core.msg.ResultUtils.success;
/**
 * 谱文控制器
 *
 * @author yanwei
 * @date 2023-05-05 15:44:28
 */
@RestController
@Api(tags = "后台管理 谱文 相关APIS")
@AdminVersionSwagger
public class XyGenealogyController {

    @Resource
    private XyGenealogyService xyGenealogyService;

    /**
     * 查询谱文
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @GetMapping("/xyGenealogy/page")
    @BusinessLog(title = "谱文_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("谱文_查询")
    public Result<PageResult<XyGenealogy>> page(XyGenealogyParam xyGenealogyParam) {
        PageResult<XyGenealogy> page = xyGenealogyService.page(xyGenealogyParam);
        return success(page);
    }

    /**
     * 添加谱文
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @PostMapping("/xyGenealogy/add")
    @BusinessLog(title = "谱文_增加", opType = LogAnnotionOpTypeEnum.ADD)
    @ApiOperation("谱文_增加")
    public Result add(@RequestBody @Validated(XyGenealogyParam.add.class) XyGenealogyParam xyGenealogyParam) {
            xyGenealogyService.add(xyGenealogyParam);
        return success();
    }

    /**
     * 删除谱文，可批量删除
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @PostMapping("/xyGenealogy/delete")
    @BusinessLog(title = "谱文_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    @ApiOperation("谱文_删除")
    public Result delete(@RequestBody @Validated(XyGenealogyParam.delete.class) List<XyGenealogyParam> xyGenealogyParamList) {
            xyGenealogyService.delete(xyGenealogyParamList);
        return success();
    }

    /**
     * 编辑谱文
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @PostMapping("/xyGenealogy/edit")
    @BusinessLog(title = "谱文_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    @ApiOperation("谱文_编辑")
    public Result edit(@RequestBody @Validated(XyGenealogyParam.edit.class) XyGenealogyParam xyGenealogyParam) {
            xyGenealogyService.edit(xyGenealogyParam);
        return success();
    }

    /**
     * 查看谱文
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @GetMapping("/xyGenealogy/detail")
    @BusinessLog(title = "谱文_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    @ApiOperation("谱文_查看")
    public Result<XyGenealogy> detail(@Validated(XyGenealogyParam.detail.class) XyGenealogyParam xyGenealogyParam) {
        XyGenealogy detail =   xyGenealogyService.detail(xyGenealogyParam);
        return success(detail);
    }

    /**
     * 谱文列表
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @GetMapping("/xyGenealogy/list")
    @BusinessLog(title = "谱文_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("谱文_列表")
    public Result<List<XyGenealogy>> list(XyGenealogyParam xyGenealogyParam) {
        List<XyGenealogy> list  =   xyGenealogyService.list(xyGenealogyParam);
        return success(list);
    }

    /**
     * 导出系统用户
     *
     * @author yanwei
     * @date 2023-05-05 15:44:28
     */
    @Permission
    @GetMapping("/xyGenealogy/export")
    @BusinessLog(title = "谱文_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
    @ApiOperation("谱文_导出")
    public void export(XyGenealogyParam xyGenealogyParam) {
        xyGenealogyService.export(xyGenealogyParam);
    }

}
